<?php

use yii\grid\GridView;
use common\helpers\Html;

$this->title = '用户管理';
$this->params['breadcrumbs'][] = ['label' => $this->title];

?>

<div class="row">
    <div class="col-xs-12">
        <div class="box">
            <div class="box-header">
                <h3 class="box-title">
                    <?= $this->title; ?>
                    <small></small>
                </h3>
                <div class="box-tools">
                    <?= Html::create(['ajax-edit'], '创建', [
                        'data-toggle' => 'modal',
                        'data-target' => '#ajaxModal',
                    ]) ?>
                </div>
            </div>
            <div class="box-body table-responsive">
                <?= GridView::widget([
                    'dataProvider' => $dataProvider,
                    'filterModel' => $searchModel,
                    // 重新定义分页样式
                    'tableOptions' => ['class' => 'table table-hover'],
                    'columns' => [
                        [
                            'class' => 'yii\grid\SerialColumn',
                        ],
                        'member_name',//会员用户名
                        'member_nickname',//会员昵称
                        //'member_auth_state',//是否是回收员
                        [
                            'attribute' => 'member_auth_state',
                            'value' => function($dataProvider) {
                               // return $dataProvider->member_auth_state == 0 ? '否' : '是';
                                if($dataProvider->member_auth_state == 0){
                                    return '否';
                                }elseif ($dataProvider->member_auth_state == 1){
                                    return '审核中';
                                }elseif ($dataProvider->member_auth_state == 2){
                                    return '审核失败';
                                }
                                elseif ($dataProvider->member_auth_state == 3){
                                    return '是';
                                }
                            }
                        ],
                       // 'member_avatar',//会员头像
                        [
                            'attribute'=>'member_avatar',
                            'format' => 'raw',
                            'value' => function($model){
                                return Html::img($model->member_avatar,['width'=>'80px']);
                            }
                        ],
                        'member_mobile',//会员手机号码
                        'member_points',//会员积分
                        'available_predeposit',//会员余额
                        [
                            'header' => "操作",
                            'class' => 'yii\grid\ActionColumn',
                            'template' => '{ajax-edit} {status} {destroy}',
                            'buttons' => [
                                'ajax-edit' => function ($url, $model, $key) {
                                    return Html::edit(['ajax-edit', 'id' => $model->id], '编辑', [
                                        'data-toggle' => 'modal',
                                        'data-target' => '#ajaxModal',
                                    ]);
                                },
                                'status' => function ($url, $model, $key) {
                                    return Html::status($model->status);
                                },
                                'destroy' => function ($url, $model, $key) {
                                    return Html::delete(['destroy', 'id' => $model->id]);
                                },
                            ],
                        ],
                    ],
                ]); ?>
            </div>
        </div>
    </div>